package cn.com.pg.b2b.pd.truck.appointment.management.service.exception;

import cn.com.pg.b2b.pd.truck.appointment.management.service.common.ResponseDTO;
import cn.com.pg.b2b.pd.truck.appointment.management.service.common.ReturnCode;
import lombok.Data;

/**
 * @ClassName CommonException
 * @Description:
 * @Author xzc
 * @Date 2021/8/24
 * @Version V1.0
 **/
@Data
public class CommonException extends RuntimeException {

    private final Integer code;

    private final String message;

    public CommonException(ResponseDTO<Object> responseDTO) {
        this.code = responseDTO.getCode();
        this.message = responseDTO.getMessage();
    }

    public CommonException(ReturnCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMessage();
    }

    public CommonException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
}
